package com.ccb.cloud.rca.appservice.controller.assetsupervise;


import com.ccb.cloud.rca.appservice.dao.DO.assetsupervise.User;
import com.ccb.cloud.rca.appservice.dto.ReqPaginationBase;
import com.ccb.cloud.rca.appservice.dto.assetsupervise.UserQueryDTO;
import com.ccb.cloud.rca.appservice.service.assetsupervise.UserService;
import com.ccb.cloud.rca.appservice.vo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wang
 * @Description Index
 * @create 2021-09-13 11:57
 */
@RestController
@RequestMapping("/grade")
public class Index {
    @Autowired
    private UserService userService;

    /**
     * 新增对象
     * @param user
     * @return
     */
    @RequestMapping(value="/addObject",method= RequestMethod.POST)
    public ResultBean addObject(@RequestBody User user){
        userService.addObject(user);
        return ResultBean.getSuccessRs("");
    }
    /**
     * 修改对象
     * @param user
     * @return
     */
    @RequestMapping(value="/updateObject",method= RequestMethod.POST)
    public ResultBean updateObject(@RequestBody User user){
        userService.updateObject(user);
        return ResultBean.getSuccessRs("");
    }
    /**
     * 查询所有
     * @return
     */
    @RequestMapping(value="/findList",method= RequestMethod.POST)
    public ResultBean findList(@RequestBody User user){
        return ResultBean.getSuccessRs(userService.findList(user));
    }
    /**
     * 分页查询
     * @return
     */
    @RequestMapping(value="/findPage",method= RequestMethod.POST)
    public ResultBean findPage(@RequestBody ReqPaginationBase<UserQueryDTO> userDto){
        return ResultBean.getSuccessRs(userService.findPage(userDto));
    }

    /**
     * 删除对象
     * @return
     */
    @RequestMapping(value="/deleteObject",method= RequestMethod.POST)
    public ResultBean deleteObject(@RequestBody User user){
        userService.deleteObject(user);
        return ResultBean.getSuccessRs("");
    }
    /**
     * 查询一条
     * @return
     */
    @RequestMapping(value="/findOne",method= RequestMethod.POST)
    public ResultBean findOne(@RequestBody User user){
        return ResultBean.getSuccessRs(userService.findOne(user));
    }
}
